// 管理extension.list标签
var managerVersion = Vue.component('managerVersion', {
    template: readComponentHTML("managerVersion"),
    data() {
        return {
            updateVersion: {
                newVersion : '0.0.0-SNAPSHOT'
            },
            data:[],
            isEdit: false,
            rules: {
                gitUrl: [
                    {required: true, message: '请输入仓库地址', trigger: 'blur'},
                ],
                branch: [
                    {required: true, message: '请输入仓库分支', trigger: 'blur'}
                ]
            }
        };
    },
    mounted() {
        this.init();
    },
    methods: {
        updateBom: function () {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/replace/' + that.updateVersion.newVersion)
                .then(function (response) {
                    that.init();
                    that.closeLoading();
                });
        },
        updateBomOnly: function (index, row) {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/replace/' + that.updateVersion.newVersion + "/" + row.name)
                .then(function (response) {
                    that.init();
                    that.closeLoading();
                });
        },
        clone: function () {
            this.reqeust('cloneBat');
        },
        commit: function () {
            this.reqeust('commitBat');
        },
        update: function () {
            this.reqeust('updateLocalBat');
        },
        reqeust: function (path) {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/' + path)
                .then(function (response) {
                    that.init();
                    that.closeLoading();
                });
        },
        upload: function () {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/upload')
                .then(function (response) {
                    that.closeLoading();
                });
        },
        uploadOnly: function (index, row) {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/upload/' + row.name )
                .then(function (response) {
                    that.closeLoading();
                });
        },
        init: function () {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/find')
                .then(function (response) {
                    if (response.data) {
                        that.data = response.data;
                        that.getNextMaxVersion();
                    }
                    that.closeLoading();
                });
        },
        getNextMaxVersion: function () {
            var that = this;
            that.openLoading();
            axios.get('/version/controll/build/max/version')
                .then(function (response) {
                    if (response.data) {
                        that.updateVersion.newVersion = response.data;
                    }
                    that.closeLoading();
                });
        }
    }
})